<template>
    <div>
        	<div class="bigDiv">
			<div style="border-bottom: solid 0.2rem #f5f5f5">
				<a href="url" onclick="javascript:window.history.go(-1); return false;" style="position: absolute;"><img  src="../../assets/goback.png"  style="float: left;margin-top: 0.1rem;"/></a>
				<p style="text-align: center;font-weight: 600;line-height: 1rem;">账户信息</p>
			</div>
			<div class="content">
				<div style="border-bottom: solid 1px #f5f5f5">
					<p class="cont-wen">账 号</p>
					<input disabled class="w-input" v-model="userInfo.username" type="text"  placeholder="请输入账号">
				</div>
				<div style="border-bottom: solid 1px #f5f5f5">
					<p class="cont-wen">姓 名</p>
					<input disabled class="w-input"  v-model="userInfo.name" type="text"  placeholder="请输入您的姓名">
				</div>
				<div style="border-bottom: solid 1px #f5f5f5">
					<p class="cont-wen">手 机</p>
					<input class="w-input" type="text" v-model="form.mobile"  placeholder="请输入您的手机号码">
				</div>
				<div style="border-bottom: solid 1px #f5f5f5">
					<p class="cont-wen">密 码</p>
					<input class="w-input" type="password"  v-model="form.password"  placeholder="请输入密码">
				</div>
			</div>
			<div id="footer">
				<p id="footer_p1" @click="submit">
					<span id="footer_span1">提交</span>
				</p> 
			</div>
		</div>
    </div>
</template>
<script>
import {updateSales} from "@/api/index"
export default {
    data() {
        return {
          userInfo:{},
          form:{
            mobile:'',
            password:''
          },
        };
    },
    created() {
      this.userInfo=JSON.parse(localStorage.getItem('userInfo'));
	  this.form.mobile=this.userInfo.mobile
    },
    mounted() {
    },
    methods: {
        submit(){
          if(!this.form.mobile||!this.form.password){
            this.$toast('手机号或密码不能为空')
            return
          }
          if(!/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(this.form.mobile)){
            this.$toast('手机号格式错误')
          }else{
            updateSales({
              mobile:this.form.mobile,
              password:this.form.password
            }).then(res=>{
              if(res.code===200){
                this.$toast('修改成功')
               setTimeout(()=>{
                 this.$router.replace('/index')
               },1500)
              }else{
                this.$toast(res.msg)
              }
            })
          }
        },
    }
};
</script>
<style scoped  lang='scss'>
@import './index.scss';
</style>